<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    // 中文编码(编码中文和一些特殊符号 字母和数字没有影响)
    // encodeURI()
    // encodeURIComponent()    编码范围更广

    var str = "今天天气不错!asdasd123123+-*/%";
    var enStr_1 = encodeURI(str);
    console.log(enStr_1);
    var enStr_2 = encodeURIComponent(str);
    console.log(enStr_2);

    // 解码
    // decodeURI()
    // decodeURIComponent()

    var deStr_1 = decodeURI(enStr_1);
    console.log(deStr_1);
    var deStr_2 = decodeURIComponent(enStr_2);
    console.log(deStr_2);
</script>   
</html>